import { create } from 'zustand';
import { persist } from 'zustand/middleware';
import { KeyStore } from './type'

const keyStore = create<KeyStore>()(
    persist(
        (set) => ({
            user: '',
            key: 'dataset-uag1CEgz35ZfP7uKu2Phkw3V',
            RAGFlowKey: 'ragflow-IxMjJiYWQwMDkxODExZjA4YTRlM2NlY2',
            datase: {},
            setKey: (key) => {
                set({ key });
            },
            setUser: (user) => {
                set({ user })
            },
            setDatase: (datase) => {
                set({ datase })
            }
        }),
        {
            name: 'key-store', // 持久化存储的名称
            partialize: (state) => ({
                user: state.user,
                // key: state.key, 
                datase: state.datase,
            }),
        }
    )
);

export default keyStore;